package com.edushare.common.vo;

import java.util.List;

import com.edushare.common.constants.ConfigPropertyName;
import com.edushare.common.file.AssignmentFileProcessingStrategy;
import com.edushare.common.file.IFileProcessStrategy;
import com.edushare.common.global.SystemGlobals;
import com.edushare.common.util.URLUtils;
import com.edushare.common.vo.FileDirectories.DIRECTORY_OWNER_TYPE;
import com.edushare.common.vo.auto._AssignmentFiles;
import com.edushare.common.vo.interfaces.IFileUploadableWithMetadata;

public class AssignmentFiles extends _AssignmentFiles implements IFileUploadableWithMetadata {

	private static final long serialVersionUID = -7848130030764864245L;
	public static final int ASSIGNMENT_FILE_VISIBILITY_TO_ALL				= 10;
	public static final int ASSIGNMENT_FILE_VISIBILITY_TO_MODS				= 20;

	public String getFileDownloadUrl(){
		String path = getFilePath();
		return URLUtils.getUrlFromRelativePath(path);
	}
	
	/** IFileUploadable implementation starts 
	 * NOTE: setFilePath, getFilePath are already implemented in super
	 */
	
	public List<String> getAllowedFileExtentions() {
		/*List<String> allowedFileTypes = Arrays.asList(SystemGlobals.getInstance().
														getConfigProperty(ConfigPropertyName.UPLOAD_IMAGE_FILE_EXTNS)
														.split(","));
		return allowedFileTypes;*/
		return null;
	}

	public Integer getMaxFileSizeInKb() {
		return Integer.parseInt(SystemGlobals.getInstance().
									getConfigProperty(ConfigPropertyName.UPLOAD_ASSIGNMENT_MAXSIZE_KB));
	}

	public String getSeoFileName() {
		/*String seoName = "Assignment";
		if(getAssignment()!=null && StringUtil.isValid(getAssignment().getAssignmentTitle()))
			if(getAssignment().getAssignmentTitle().length() > 30){
				seoName = getAssignment().getAssignmentTitle().substring(0, 30);
			}else{
				seoName = getAssignment().getAssignmentTitle();
			}
		*/
		return null;
	}
	
	public IFileProcessStrategy getFileProcessingStrategy() {
		return new AssignmentFileProcessingStrategy();
	}	

	public String getUploadedFileUrl() {
		return URLUtils.getImageUrlFromRelativePath(getFilePath());
	}
	
	public FileUploadInfo getFileUploadInfo() {
		return super.getUploadedFileMetadata();
	}

	public void setFileUploadInfo(FileUploadInfo fuvo) {
		super.setUploadedFileMetadata(fuvo);		
	}
	
	public DIRECTORY_OWNER_TYPE getObjectType() {
		return null;
	}
	
	public int getObjectPrimaryKey() {
		return 0;
	}

	public int getFileUploadPrivacyLevel() {
		// TODO Auto-generated method stub
		return 0;
	}

	public void setFileUploadPrivacyLevel(int fupl) {
		// TODO Auto-generated method stub
		
	}

	public String getTitle() {
		return getTitle();
	}
	
	/** IFileUploadable implementation ends */

}
